package com.auto.oracle;

final class createParams {
	private String ostype = null,
			       dbtype = null,
			       charsetType = null,
			       nationalType = null,
			       oraclePwd = null,
			       oraclePath = null,
			       installDevPath = null,
			       memUnit = null,
			       instanceName = null,
			       databasePwd = null,
			       installContent = null;
	private double instanceMem = 0;
	private boolean hasDev = false;
	
	public String getInstallContent() {
		return installContent;
	}
	public void setInstallContent(String installContent) {
		this.installContent = installContent;
	}
	
	public String getOstype() {
		return ostype;
	}
	public String getCharsetType() {
		return charsetType;
	}
	public String getNationalType() {
		return nationalType;
	}
	public String getOraclePwd() {
		return oraclePwd;
	}
	public String getOraclePath() {
		return oraclePath;
	}
	public String getInstallDevPath() {
		return installDevPath;
	}
	public String getMemUnit() {
		return memUnit;
	}
	public double getInstanceMem() {
		return instanceMem;
	}
	public boolean getHasDev() {
		return hasDev;
	}
	public void setOstype(String ostype) {
		this.ostype = ostype;
	}
	public void setCharsetType(String charsetType) {
		this.charsetType = charsetType;
	}
	public void setNationalType(String nationalType) {
		this.nationalType = nationalType;
	}
	public void setOraclePwd(String oraclePwd) {
		this.oraclePwd = oraclePwd;
	}
	public void setOraclePath(String oraclePath) {
		this.oraclePath = oraclePath;
	}
	public void setInstallDevPath(String installDevPath) {
		this.installDevPath = installDevPath;
	}
	public void setMemUnit(String memUnit) {
		this.memUnit = memUnit;
	}
	public void setInstanceMem(int instanceMem) {
		this.instanceMem = instanceMem;
	}
	public void setHasDev(boolean hasDev) {
		this.hasDev = hasDev;
	}
	public String getInstanceName() {
		return instanceName;
	}
	public String getDatabasePwd() {
		return databasePwd;
	}
	public void setInstanceName(String instanceName) {
		this.instanceName = instanceName;
	}
	public void setDatabasePwd(String databasePwd) {
		this.databasePwd = databasePwd;
	}
	public String getDbtype() {
		return dbtype;
	}
	public void setDbtype(String dbtype) {
		this.dbtype = dbtype;
	}
	
	public int getOsCode(){
		if(this.ostype.indexOf("6.") > 0)
			return 6;
		else if(this.ostype.indexOf("7.") > 0)
			return 7;
		return 8;
	}
	
	public long getOracleMem(){
		if(this.memUnit.equals("GB"))
			return Math.round(this.instanceMem * 1024);
		return Math.round(this.instanceMem);
	}
	
	public int getShm(){
		return Math.round(getOracleMem() / 1024) + 4;
	}
	
	public long getProcess(){
		return Math.round(getOracleMem() / 4.4);
	}
	
	public long getFilemax(){
		return getProcess() * 512;
	}
	
	public long getShmax(){
		return Math.round(getOracleMem() * 0.8 * 1024 * 1024 * 1.05);
	}
	
	public long getShmall(){
		return Math.round(getShmax() / 4096);
	}
	
	public long getSem1(){
		return getProcess() + 10;
	}
	
	public int getSem4(){
		return 128;
	}
	
	public long getSem2(){
		return getSem1() * getSem4();
	}
	
	public long getSem3(){
		return getSem1();
	}
	
	public String getVersion(){
		if(this.dbtype.equals("11.2.0.1"))
			return "11.2.0";
		else if(this.dbtype.equals("11.2.0.4"))
			return "11.2.0";
		else if(this.dbtype.equals("12.1.0.2"))
			return "12.1.0";
		else if(this.dbtype.equals("12.2.0.1"))
			return "12.2.0";
		else if(this.dbtype.equals("12.2.0.2"))
			return "18.0.0";
		else if(this.dbtype.equals("12.2.0.3"))
			return "19.3.0";
		return "11.2.0";
	}
}
